// /common/http.api.js

//首页测试
// let indexUrl = '/api/shop';

// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
const install = (Vue, vm) => {
	/**
	 * 首页
	 */
	//最新
	let index = params => vm.$u.get('/discuss/page/oneAndone', params);

	/**
	 * 测试
	 */
	let getUserFood = params => vm.$u.get('/userlike', params);
	let getLikeFood = params => vm.$u.post('/taste', params);
	
	let getFoodData = params => vm.$u.get('/taste', params);
	let updUserlike = params => vm.$u.post('/userlike', params);
	let listUser = params => vm.$u.post('/discuss/recommend', params); //查询推荐点评
	
	
	/**
	 * 榜单
	 */
	//test
	let getPageShop = params => vm.$u.get('/shop/page', params);
	//近7日,近30日
	let getDayOrder = params => vm.$u.get('/discuss/DayPage', params);
	//商家发布
	let getShopRemmend = params => vm.$u.get('/discuss/ShopOrderPage', params);
	
	/**
	 * 个人
	 */
	//修改用户表
	let intUpdUserView = params => vm.$u.post('/user', params)
	//增加用户点赞数
	let addUserLike = params => vm.$u.post('/user/addlike', params)
	//减少用户点赞数
	let subUserLike = params => vm.$u.post('/user/sublike', params)
	//找出点赞
	let getLike = params => vm.$u.get('/like', params)
	//查询个人点评
	let getByIdDiscuss = params => vm.$u.get('/discuss/myDiscuss', params)
	//按id查询个人信息
	let getByIdUser = params => vm.$u.get('/user/getByIdUser', params)
	
	/**
	 * 商家
	 */
	//商家入驻
	let getShop = params => vm.$u.post('/shop', params)
	//根据商家ID查询信息
	let getShopData = params => vm.$u.get('/shop', params)
	
	
	//用户

	/**
	 * 点评
	 */
	//上传图片
	let uploadDiscuss = params => vm.$u.post('/discuss/arrupload', params,{'Content-Type':'multipart/form-data; charset=utf-8'})
	//修改点评
	let intUpdDiscuss = params => vm.$u.post('/discuss', params)
	//查看点评详情
	let getDetailDiscuss = params => vm.$u.get('/discuss/view/detail', params);
	//查看点评下的评论
	let getDiscussSubComment = params => vm.$u.get('/discuss/view/detail/subComment',params);
	//评论表点赞增加
	let addDiscussLike = params => vm.$u.get('/discuss/view/detail/addLike', params)
	//评论表点赞增加减少
	let subDiscussLike = params => vm.$u.get('/discuss/view/detail/subLike', params)
	// 点评的评论点赞否定增加
	let addDiscussDislike = params => vm.$u.get('/discuss/view/detail/addDislike', params)
	//点评的评论点赞否定减少
	let subDiscussDislike = params => vm.$u.get('/discuss/view/detail/subDislike', params)
	
	/**
	 * 点赞表
	 */
	//点评的评论点赞增加
	let addLike = params => vm.$u.post('/like/addLike', params)
	//点评的评论点赞减少
	let calLike = params => vm.$u.get('/like/calLike', params)
	
	// 此处使用了传入的params参数，一切自定义即可
	// let getInfo = (params = {}) => vm.$u.post(indexUrl, params);
	
	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {
		index,
		getPageShop,
		intUpdUserView,
		uploadDiscuss,
		intUpdDiscuss,
		getDetailDiscuss,
		getDiscussSubComment,
		addLike,
		calLike,
		addUserLike,
		subUserLike,
		getLike,
		addDiscussLike,
		subDiscussLike,
		addDiscussDislike,
		subDiscussDislike,
		getByIdDiscuss,
		getByIdUser,
		getDayOrder,
		getShop,
		getShopRemmend,
		getUserFood,
		getLikeFood,
		getFoodData,
		updUserlike,
		listUser,
		getShopData
	};
}

export default {
	install
}
